{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#programming_fever\n",
    "#cartoonizing an image using OpenCV\n",
    "import cv2\n",
    "img_rgb = cv2.imread(\"E://OpenCV//bmw.png\") \n",
    "numBilateralFilters = 30  \n",
    "\n",
    "for _ in range(numBilateralFilters): \n",
    "    img_rgb = cv2.bilateralFilter(img_rgb, 9, 9, 7) \n",
    "\n",
    "img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_RGB2GRAY)\n",
    " \n",
    "img_blur = cv2.medianBlur(img_gray, 3) \n",
    " \n",
    "img_edge = cv2.adaptiveThreshold(img_blur, 255, \n",
    "                                         cv2.ADAPTIVE_THRESH_MEAN_C, \n",
    "                                         cv2.THRESH_BINARY, 9, 2)  \n",
    "\n",
    "img_edge = cv2.cvtColor(img_edge, cv2.COLOR_GRAY2RGB) \n",
    "cv2.imshow(\"img_rgb\", img_rgb) \n",
    "cv2.imshow(\"img_edge\", img_edge) \n",
    "\n",
    "res=cv2.bitwise_and(img_rgb, img_edge) \n",
    "  \n",
    "cv2.imshow(\"Cartoon version\", res) \n",
    "cv2.waitKey(0) \n",
    "cv2.destroyAllWindows() \n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
